package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.service.MenuService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class MenuController {

    @Reference
    private MenuService menuService;

    // /menu/findPage. 分页查询
    @RequestMapping("/menu/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
        return menuService.findPage(queryPageBean);
    }

    // /menu/add
    @RequestMapping("/menu/add")
    public Result add(@RequestBody Map map) {
        return menuService.add(map);
    }

    // /menu/findById
    @RequestMapping("/menu/findById")
    public Result findById(Integer id) {
        return menuService.findById(id);
    }

    // /menu/edit 修改表单
    @RequestMapping("/menu/edit")
    public Result edit(@RequestBody Map map) {
        return menuService.edit(map);
    }

    // /menu/delete
    @RequestMapping("/menu/delete")
    public Result delete(Integer id){
        return menuService.delete(id);
    }
}
